/**
 * Created by 2015302580057 on 2017/7/12.
 */
function login() {
    $.ajax({
            url: '/Login',
            type: "POST",
            data: {
                myemail: $("#myemail").val(),
                password: $("#password").val(),
                checkcode: $("#checkcode").val()
            }
            ,
            success: function (data) {
                switch (data['code']) {
                    case 0:
                        window.location.href = "giggleHomePage.jsp"
                        break;
                    case 1:
                        alert("用户不存在！");
                        break;
                    case 2:
                        alert("验证码错误！");
                        break;
                    case 3:
                        alert("密码错误！");
                        break;
                }
            }
            ,
            error: function (err) {
                console.log(err);
            }
        }
    );
}

//变更验证码
function changeImage(img) {
    /*
     * img.src = img.src;相当于img.src = /day06/ResponseDemo4;
     * img.src = img.src;不可以的原因还是和缓存相关，如果后面不跟随机数，意味着缓存里面有图片，请求就会去拿缓存
     * 后面跟上随机数，url地址发生变化，向服务器发请求！！！
     */
    img.src = img.src + "?" + new Date().getTime();
}